Skip to content

fix: retry transient HTTP errors (529/502/503/504) without --wait - #377

Merged
umputun merged 1 commit into
masterfrom
fix/transient-http-retry
Jun 8, 2026
Merged

umputun merged 1 commit into
masterfrom
fix/transient-http-retry

Conversation

@umputun

@umputun umputun commented Jun 8, 2026

Copy link
Copy Markdown
Owner

529 Overloaded and the 502/503/504 gateway errors lived in claude_limit_patterns, which only auto-retries when --wait is set, and even then sleeps the full quota-window duration. Without --wait a transient 529 hard-failed the run (originally hit during claude review 2).

these are short-lived server hiccups, not account-quota limits. Moved them to claude_retry_patterns: checked first, auto-retried through the existing timeout-style phase path, no --wait needed, bounded by iteration limits. API Error: 500 stays out since it can be a deterministic server failure, and is still caught by the broad API Error: error pattern. Precedence is retry -> limit -> error, so a no-signal 529 matches the retry tier first.

also added a fixed 5s backoff (retryBackoff in pkg/processor/phase/phase.go) before re-running a timed-out or transiently-failed iteration in the task loop and review-iteration loop. This covers all retry paths, including the pre-existing session/idle-timeout retries. The first-review soft-skip is not a retry, so it has no backoff.

tests: updated default-pattern assertions in pkg/config/values_test.go, renamed TestTaskPhase_Run_TimeoutContinuesWithoutSleeping -> TestTaskPhase_Run_TimeoutBacksOffThenContinues and asserted the backoff, added a backoff assertion to the review Loop-timeout test. Docs synced (README, llms.txt, CLAUDE.md).

529 Overloaded and the 502/503/504 gateway errors were in claude_limit_patterns,
which only retries when --wait is set, and then waits the full quota duration.
without --wait a transient 529 hard-failed the run (seen during claude review 2).

these are short-lived server hiccups, not account-quota limits, so they move to
claude_retry_patterns: checked first, auto-retried via the existing timeout path,
no --wait needed, bounded by iteration limits. 500 stays out since it can be a
deterministic failure, still caught by the broad `API Error:` error pattern.

also add a fixed 5s backoff before re-running a timed-out or transiently-failed
iteration in the task and review loops, so retries don't hammer immediately.
Copilot AI review requested due to automatic review settings June 8, 2026 19:31
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying ralphex with  Cloudflare Pages  Cloudflare Pages

Latest commit: 1cb32ed
Status: ✅  Deploy successful!
Preview URL: https://1ac107dd.ralphex.pages.dev
Branch Preview URL: https://fix-transient-http-retry.ralphex.pages.dev

View logs

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts ralphex’s Claude pattern handling and retry behavior so short-lived server-side HTTP hiccups (529/502/503/504) are automatically retried even when --wait is not enabled, and adds a small fixed backoff before re-running timeout/transient-retry iterations in the task and internal review loops.

Changes:

  • Reclassified API Error: 529/502/503/504 from Claude “limit” patterns to “retry” patterns so they follow timeout-style bounded retries without --wait.
  • Added a fixed retryBackoff (5s) before continuing after a timed-out/transient-retry iteration in task and review loops.
  • Updated tests and docs to reflect the new defaults and the new backoff behavior.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated no comments.

Show a summary per file
File Description
README.md Updates config docs to reflect retry-vs-limit pattern behavior and the new 5s backoff.
pkg/processor/phase/task.go Adds retryBackoff sleep before retrying after a timeout/transient retry in the task loop.
pkg/processor/phase/task_test.go Renames/updates timeout test to assert the new backoff sleep occurs.
pkg/processor/phase/review.go Adds retryBackoff sleep before retrying after a timeout/transient retry in the internal review loop.
pkg/processor/phase/review_test.go Updates timeout test to assert the new backoff sleep occurs (adds time import).
pkg/processor/phase/phase.go Introduces shared retryBackoff = 5s constant for task/review loops.
pkg/config/values_test.go Updates embedded-default assertions for Claude limit vs retry patterns.
pkg/config/defaults/config Updates default ini values/comments to move 529/502/503/504 into claude_retry_patterns.
llms.txt Syncs documentation of retry/limit behavior and defaults.
CLAUDE.md Syncs documentation of retry precedence, moved patterns, and the new backoff.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@umputun
umputun merged commit ec5d829 into master Jun 8, 2026
6 checks passed
@umputun
umputun deleted the fix/transient-http-retry branch June 8, 2026 19:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants